﻿using System;
using System.Collections.Generic;
using System.Text;
using T.FAS.Runtime.Action.Entity;
using T.FAS.Runtime.Action.Dao;
using T.FAS.Runtime.Action.SPI;

namespace T.FAS.Runtime.Action.Service
{
    public class ActionRTPHelpService
    {
        public List<DataBaseInfoView> GetDBInfoViews(List<string> dbCodes)
        {
            var dbList = new List<DataBaseInfo>();
            dbCodes.ForEach(t=>
            {
                var dbInfo = ActionRTPHelpCacheService.GetInstance().GetDataBaseInfoFromLocalCache(t);
                if (dbInfo == null)
                {
                    dbInfo = new DataBaseInfoDao().GetDefaultDataBaseInfoByCode(t);
                    if (dbInfo != null &&!string.IsNullOrEmpty(dbInfo.Code) &&!string.IsNullOrEmpty(dbInfo.ConnectionKey))
                    {
                        ActionRTPHelpCacheService.GetInstance().AddDataBaseInfoCache(dbInfo);
                        dbList.Add(dbInfo);
                    }
                }
            });
            return new DataBaseInfoViewDao().GetDataBaseInfoViews(dbList);
        }
    }
}
